package com.best.config;

import com.best.service.User;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.stereotype.Component;

/**
 * @author Jiang Akang
 * employeeId: BG435424
 * @date 2021/5/30
 **/

//@Component
public class BestFactoryBean implements FactoryBean<User> {

    private String userInfo;

    public User getObject() throws Exception {
        User User = new User();
        String[] infos = userInfo.split(",");
        User.setId(Integer.parseInt(infos[0]));
        User.setName(infos[1]);
        return User;
    }

    public Class<User> getObjectType() {
        return User.class;
    }

    public boolean isSingleton() {
        return false;
    }

    public String getUserInfo() {
        return this.userInfo;
    }

    // 接受逗号分割符设置属性信息
    public void setUserInfo(String userInfo) {
        this.userInfo = userInfo;
    }
}
